package 笔试.四4399;

import java.util.Arrays;
import java.util.Scanner;

public class n个数和被k整除 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String numstr = sc.nextLine();
        String[] strs = numstr.split(" ");
        int[] nums = new int[strs.length];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = Integer.parseInt(strs[i]);
        }
        Solution solution = new Solution();
        int k = sc.nextInt();
        boolean res = solution.hasSumNums(nums, k);
        System.out.println(res);
    }

    static class Solution {
        public boolean hasSumNums(int[] nums, int k) {
            Arrays.sort(nums);
            int sum = 0;
            int index = 0;
            int dept = 0;
            return backtracking(nums, index, k, sum, dept);
        }

        private boolean backtracking(int[] nums, int index, int k, int sum, int dept) {
            if (dept >= 2 && sum % k == 0) {
                return true;
            }
            for (int i = index; i < nums.length; i++) {
                if (backtracking(nums, index + 1, k, sum + nums[index], dept + 1)) {
                    return true;
                }
            }
            return false;
        }
    }
}
